/*
 * @Author: szx
 * @Date: 2022-01-14 15:12:04
 * @LastEditTime: 2022-01-14 15:20:49
 * @Description: 
 * @FilePath: \leetcode\500-599\518\518.js
 */
/**
 * @param {number} amount
 * @param {number[]} coins
 * @return {number}
 */
var change = function (amount, coins) {
    // dp[j] 表示：填满j（包括j）这么大容积的包，有dp[j]种方法
    const dp = new Array(amount + 1).fill(0);
    dp[0] = 1;
    for (let i = 0; i < coins.length; i++) {
        for (let j = coins[i]; j <= amount; j++) {
            dp[j] += dp[j - coins[i]];
        }
    }
    return dp[amount];
};
console.log(change(3, [2]))